package com.ruoyi.framework.config.mybatisplus;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.Date;

@Component
public class AutoFillHandler implements MetaObjectHandler {
	private Logger logger= LoggerFactory.getLogger(AutoFillHandler.class);
	@Override
	public void insertFill(MetaObject metaObject) {
		this.strictInsertFill(metaObject, "createdTime", Date.class, new Date());
		this.strictInsertFill(metaObject, "updatedTime", Date.class, new Date());
	}
	
	@Override
	public void updateFill(MetaObject metaObject) {
		this.strictUpdateFill(metaObject, "updatedTime", Date.class, new Date());
	}
}
